Skip to content

(Pet Frames) Fix Lua error on pet name update in instanced content#72

Merged
DanderBot merged 1 commit into
DanderBot:mainfrom
Krathe82:fix/pet-name-secret-value-truncation
May 11, 2026
Merged

(Pet Frames) Fix Lua error on pet name update in instanced content#72
DanderBot merged 1 commit into
DanderBot:mainfrom
Krathe82:fix/pet-name-secret-value-truncation

Conversation

@Krathe82

@Krathe82 Krathe82 commented May 10, 2026

Copy link
Copy Markdown
Contributor

Summary

DF:UpdatePetName called #name and name:sub() on the result of GetUnitName, which throws a Lua error in delves and encounters where unit names are returned as secret string values in Midnight 12.0. GetUnitName does not guarantee a non-secret result in instanced content (contrary to the assumption in commit b36ffc3).

Routes truncation through DF:UTF8Len / DF:UTF8Sub (the same helpers used in Frames/Bars.lua:UpdateName), which both gate on issecretvalue internally and return safe defaults when the input is secret. The truncation branch silently no-ops, SetText still receives the secret string, and FontStrings render it correctly — only Lua string operations on secret values cause errors.

Supersedes PR #67, which guards the entire block with not issecretvalue(name), preventing the crash but also skipping SetText entirely — leaving the pet name text stale instead of updating it.

Also adds a maxLen > 0 guard, consistent with Bars.lua, so a max-length setting of 0 (no limit) is correctly handled.

Test plan

  • /reload while in a delve on a pet class (warlock, hunter, etc.) — no Lua error spam on pet name updates
  • Normal world pet (outside instance) — name still displays and truncates correctly when longer than petNameMaxLength
  • Boss encounters — no regression from the previous b36ffc3 fix

GetUnitName can return a secret string value in delves and encounters.
The previous code called #name and name:sub() on the result, which throws
a Lua error the moment any string operation is attempted on a secret value.

Routes truncation through DF:UTF8Len / DF:UTF8Sub, which both guard on
issecretvalue internally and return safe defaults (0 / "") when the input
is secret. The truncation branch no-ops, SetText still receives the secret
string, and FontStrings render it correctly without taint.

Supersedes PR DanderBot#67 which skipped SetText entirely on secret values, leaving
the pet name text stale rather than updating it.
@DanderBot DanderBot merged commit f2bbcbc into DanderBot:main May 11, 2026
@DanderBot

Copy link
Copy Markdown
Owner

Thanks for the PR! Merged into main and will ship in the next alpha build.

DanderBot added a commit that referenced this pull request May 11, 2026
@Krathe82 Krathe82 deleted the fix/pet-name-secret-value-truncation branch June 4, 2026 12:42
Krathe82 pushed a commit to Krathe82/DandersFrames that referenced this pull request Jun 6, 2026
…ue-truncation

(Pet Frames) Fix Lua error on pet name update in instanced content
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants